# 界面层
from house_service import *


class HouseView:
    house_operation: HouseService = HouseService()

    def list_house(self):
        print("--------------房屋列表------------------")
        print("编号\t\t房主\t\t电话\t\t地址\t\t月租\t\t状态(未出租/已出租)")
        # 得到houses列表
        houses = self.house_operation.get_house()
        for house in houses:
            print(house)
        print("--------------房屋列表显示完毕------------------")

    def add_house(self):
        print("--------------新增房源------------------")
        name = input("请输入房主姓名：")
        phone = input("请输入房主电话：")
        address = input("请输入房屋地址：")
        rent = input("请输入房屋月租：")
        state = input("请输入房屋状态：")
        # 创建House对象
        house = House(self.house_operation.id_count, name, phone, address, rent, state)
        # 调用add方法
        self.house_operation.add(house)

    def query_house(self):
        print("--------------查询房源------------------")
        find_id = input("请输入要查询的房源编号：")
        house = self.house_operation.find_by_id(find_id)
        if house is None:
            print("没有找到该房源！")
        else:
            print(house)

    def main_menu(self):
        while True:
            # 显示主菜单
            print()
            print("--------------房屋信息管理系统--------------")
            print("--------------1. 新增房源------------------")
            print("--------------2. 查询房源------------------")
            print("--------------3. 删除房源------------------")
            print("--------------4. 修改房源------------------")
            print("--------------5. 房屋列表------------------")
            print("--------------6. 退出  --------------------")
            print("------------------------------------------")
            print("请输入你的选择:(1-6)")
            key = input("请输入您的选择：")
            if key in ["1", "2", "3", "4", "5", "6"]:
                if key == "1":
                    # add_house()
                    pass
                elif key == "2":
                    # query_house()
                    pass
                elif key == "3":
                    # delete_house()
                    pass
                elif key == "4":
                    # update_house()
                    pass
                elif key == "5":
                    self.list_house()
                elif key == "6":
                    break
                else:
                    print("您输入的选项有误，请重新输入！")
